package com.hboot.demo.controller;

import com.hboot.demo.entity.User;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by [daicx] on 2017/10/24.
 */
@Controller
@EnableAutoConfiguration
@RequestMapping("/user")
public class UserController {
    @RequestMapping("/index")
    public ModelAndView index(ModelAndView mv) {
        List<User> datas = new ArrayList<User>();
        User user1 = new User();
        user1.setId(1);
        user1.setName("张三1");

        User user2 = new User();
        user2.setId(2);
        user2.setName("张三2");

        datas.add(user1);
        datas.add(user2);
        mv.addObject("datas", datas);

        mv.setViewName("user");
        return mv;
    }
}
